package com.jeecms.edu.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jeecms.edu.entity.SchoolInformation;

/**
 * database页面中检索归类
 */
@WebServlet("/ShowSchoolTypeTip")
public class ShowSchoolTypeTip extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		PrintWriter writer=response.getWriter();
		String result="";
		String schoolsql=request.getParameter("schoolsql");
		String schoolvalue=request.getParameter("schoolvalue");
		String schooltype=request.getParameter("schooltype");
		switch (schooltype) {
		case "幼儿园":
			schooltype="('幼儿园')";
			break;
		case "小学":
			schooltype="('9年制学校','12年制学校','小学')";
			break;
		case "初中":
			schooltype="('9年制学校','4年制初级中学','12年制学校','7年制完全中学')";
			break;
		case "高中":
			schooltype="('12年制学校','3年制高级中学','7年制完全中学')";
			break;
		}
		List list=SchoolInformation.checkSchoolLevel(schoolsql, schoolvalue, schooltype);
		int size=list.size();
		if (list.size()>4) {   //增加显示数量限制
			size=4;
		}
		for (int i = 0; i < size; i++) {
			Map map=(Map) list.get(i);
			String school=(String) map.get("schoolname");
			String changes="javascript:gotoDetail('"+school+"');";
			result+="<div class='school_picthread'><a href="+changes+"><img src='"+map.get("schoolimgurl")+"'/></a>"
					+"<p><a href="+changes+"><strong id='SchoolName'>"+map.get("schoolname")+"</strong>"+map.get("schoolprofile")+"</a></p></div>";
		}
		writer.append(result);
		writer.flush();
		writer.close();
	}

}
